<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master"
  AutoEventWireup="true" CodeBehind="NewsDetail.aspx.cs" Inherits="NguyenHoa.Web.Admin.NewsDetail" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxtc" %>
<%@ Register Assembly="DevExpress.Web.ASPxHtmlEditor.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxHtmlEditor" TagPrefix="dxhe" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.ASPxSpellChecker.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxSpellChecker" TagPrefix="dxwsc" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxClasses" TagPrefix="dxw" %>
<%@ Register Src="../Controls/ImageUpload.ascx" TagName="ImageUpload" TagPrefix="uc1" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
  <dxtc:ASPxTabControl ID="ASPxTabControl1" runat="server" ActiveTabIndex="0" TabSpacing="0px"
    Width="100%">
    <ClientSideEvents ActiveTabChanging="function(s, e) {onTabChange(s, e);}" />
    <TabStyle HorizontalAlign="Center" Width="55px">
    </TabStyle>
    <Tabs>
      <dxtc:Tab Name="NewsInfo" Text="<%$Resources:Strings, NewsInfo %>" TabStyle-Cursor="pointer">
      </dxtc:Tab>
      <dxtc:Tab Name="NewsContent" Text="<%$Resources:Strings, NewsContent %>" TabStyle-Cursor="pointer">
      </dxtc:Tab>
    </Tabs>
    <Paddings PaddingLeft="0px" />
  </dxtc:ASPxTabControl>
  <div style="clear: both;">
    <dxcb:ASPxCallback ID="ctrlCallback" ClientInstanceName="ctrlCallback" runat="server"
      OnCallback="ctrlCallback_Callback">
      <ClientSideEvents CallbackComplete="function(s,e){ctrlCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
    <asp:XmlDataSource ID="xdsNewsStatus" runat="server" DataFile="~/App_Data/Status.xml"
      XPath="Items/NewsStatus/Status"></asp:XmlDataSource>
  </div>
  <div id="frmNewsInfo" style="clear: both; padding-top: 10px;">
    <table style="padding-left: 30px;">
      <tr>
        <td style="padding-right: 70px;">
          <asp:Label ID="Label5" runat="server" Text="<%$Resources:Strings, PostedDate %>"
            CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxLabel ID="lblPostedDate" ClientInstanceName="lblPostedDate" runat="server"
            Font-Bold="True">
          </dxe:ASPxLabel>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 8px;">
          <asp:Label ID="Label6" runat="server" Text="<%$Resources:Strings, PostedBy %>" CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td style="padding-top: 8px;">
          <dxe:ASPxLabel ID="lblPostedBy" ClientInstanceName="lblPostedBy" runat="server" Font-Bold="True">
          </dxe:ASPxLabel>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 8px;">
          <asp:Label ID="Label10" runat="server" Text="<%$Resources:Strings, NewsCategory %>"
            CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td style="padding-top: 8px;">
          <dxe:ASPxComboBox ID="cbxCategory" ClientInstanceName="cbxCategory" runat="server"
            TextField="Name" ValueField="Id" ValueType="System.Int32">
            <ButtonStyle Width="11px">
            </ButtonStyle>
            <ItemStyle Font-Size="11pt" />
            <ValidationSettings>
              <ErrorImage Height="14px" Width="14px" />
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
            </ValidationSettings>
          </dxe:ASPxComboBox>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 5px;">
          <asp:Label ID="Label7" runat="server" Text="<%$Resources:Strings, Status %>" CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td style="padding-top: 5px;">
          <dxe:ASPxComboBox ID="cbxStatus" ClientInstanceName="cbxStatus" runat="server" TextField="Value"
            ValueField="Id" ValueType="System.String" DataSourceID="xdsNewsStatus">
            <ValidationSettings>
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
              <ErrorImage />
            </ValidationSettings>
          </dxe:ASPxComboBox>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td style="padding-top: 8px;">
          <dxe:ASPxCheckBox ID="ckbHotNews" ClientInstanceName="ckbHotNews" runat="server"
            Text="<%$ Resources:Strings, IsHotNews %>">
          </dxe:ASPxCheckBox>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 7px;">
          <asp:Label ID="Label8" runat="server" Text="<%$Resources:Strings, ApprovedDate %>"
            CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td style="padding-top: 7px;">
          <dxe:ASPxLabel ID="lblApprovedDate" ClientInstanceName="lblApprovedDate" runat="server">
          </dxe:ASPxLabel>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 8px;">
          <asp:Label ID="Label9" runat="server" Text="<%$Resources:Strings, ApprovedBy %>"
            CssClass="CommonFont"></asp:Label>
          :
        </td>
        <td style="padding-top: 8px;">
          <dxe:ASPxLabel ID="lblApprovedBy" ClientInstanceName="lblApprovedBy" runat="server">
          </dxe:ASPxLabel>
        </td>
      </tr>
    </table>
  </div>
  <div id="frmNewsContent" style="padding-top: 10px; display: none; vertical-align: middle;">
    <table class="CommonFont" width="100%">
      <tr>
        <td valign="bottom" style="padding-bottom: 8px;">
          <asp:Label ID="Label1" runat="server" Text="<%$Resources:Strings, Image %>"></asp:Label>
          :
        </td>
        <td>
          <uc1:ImageUpload ID="ImageUpload1" runat="server" />
        </td>
      </tr>
      <tr>
        <td>
          <asp:Label ID="Label2" runat="server" Text="<%$Resources:Strings, Title %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxTextBox ID="txtTitle" ClientInstanceName="txtTitle" runat="server" Width="670px">
            <ValidationSettings>
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
              <ErrorImage />
            </ValidationSettings>
          </dxe:ASPxTextBox>
        </td>
      </tr>
      <tr>
        <td valign="top" style="padding-top: 4px;">
          <asp:Label ID="Label3" runat="server" Text="<%$Resources:Strings, Summary %>"></asp:Label>
          :
        </td>
        <td>
          <dxe:ASPxMemo ID="mmSummary" ClientInstanceName="mmSummary" runat="server" Height="71px"
            Width="670px">
            <ValidationSettings>
              <ErrorFrameStyle ImageSpacing="4px">
                <ErrorTextPaddings PaddingLeft="4px" />
              </ErrorFrameStyle>
              <ErrorImage />
            </ValidationSettings>
          </dxe:ASPxMemo>
        </td>
      </tr>
      <tr>
        <td valign="top">
          <asp:Label ID="Label4" runat="server" Text="<%$Resources:Strings, Content %>"></asp:Label>
          :
        </td>
        <td>
          <dxhe:ASPxHtmlEditor ID="htmlEditor" ClientInstanceName="htmlEditor" runat="server"
            Width="670px">
            <SettingsImageUpload UploadImageFolder="~/Upload/Images/">
              <ValidationSettings AllowedContentTypes="image/jpeg,image/pjpeg,image/gif,image/png,image/x-png">
              </ValidationSettings>
            </SettingsImageUpload>
            <Images>
              <DialogFormCloseButton Height="17px" Width="17px" />
            </Images>
            <Toolbars>
              <dxhe:StandardToolbar1>
                <Items>
                  <dxhe:ToolbarCutButton>
                  </dxhe:ToolbarCutButton>
                  <dxhe:ToolbarCopyButton>
                  </dxhe:ToolbarCopyButton>
                  <dxhe:ToolbarPasteButton>
                  </dxhe:ToolbarPasteButton>
                  <dxhe:ToolbarPasteFromWordButton>
                  </dxhe:ToolbarPasteFromWordButton>
                  <dxhe:ToolbarUndoButton BeginGroup="True">
                  </dxhe:ToolbarUndoButton>
                  <dxhe:ToolbarRedoButton>
                  </dxhe:ToolbarRedoButton>
                  <dxhe:ToolbarRemoveFormatButton BeginGroup="True">
                  </dxhe:ToolbarRemoveFormatButton>
                  <dxhe:ToolbarSuperscriptButton BeginGroup="True">
                  </dxhe:ToolbarSuperscriptButton>
                  <dxhe:ToolbarSubscriptButton>
                  </dxhe:ToolbarSubscriptButton>
                  <dxhe:ToolbarInsertOrderedListButton BeginGroup="True">
                  </dxhe:ToolbarInsertOrderedListButton>
                  <dxhe:ToolbarInsertUnorderedListButton>
                  </dxhe:ToolbarInsertUnorderedListButton>
                  <dxhe:ToolbarIndentButton BeginGroup="True">
                  </dxhe:ToolbarIndentButton>
                  <dxhe:ToolbarOutdentButton>
                  </dxhe:ToolbarOutdentButton>
                  <dxhe:ToolbarInsertLinkDialogButton BeginGroup="True">
                  </dxhe:ToolbarInsertLinkDialogButton>
                  <dxhe:ToolbarUnlinkButton>
                  </dxhe:ToolbarUnlinkButton>
                  <dxhe:ToolbarInsertImageDialogButton>
                  </dxhe:ToolbarInsertImageDialogButton>
                  <dxhe:ToolbarCheckSpellingButton BeginGroup="True">
                  </dxhe:ToolbarCheckSpellingButton>
                  <dxhe:ToolbarFontColorButton>
                  </dxhe:ToolbarFontColorButton>
                  <dxhe:ToolbarBackColorButton>
                  </dxhe:ToolbarBackColorButton>
                </Items>
              </dxhe:StandardToolbar1>
              <dxhe:StandardToolbar2>
                <Items>
                  <dxhe:ToolbarParagraphFormattingEdit Width="120px">
                    <Items>
                      <dxhe:ToolbarListEditItem Text="Normal" Value="p" />
                      <dxhe:ToolbarListEditItem Text="Heading  1" Value="h1" />
                      <dxhe:ToolbarListEditItem Text="Heading  2" Value="h2" />
                      <dxhe:ToolbarListEditItem Text="Heading  3" Value="h3" />
                      <dxhe:ToolbarListEditItem Text="Heading  4" Value="h4" />
                      <dxhe:ToolbarListEditItem Text="Heading  5" Value="h5" />
                      <dxhe:ToolbarListEditItem Text="Heading  6" Value="h6" />
                      <dxhe:ToolbarListEditItem Text="Address" Value="address" />
                      <dxhe:ToolbarListEditItem Text="Normal (DIV)" Value="div" />
                    </Items>
                  </dxhe:ToolbarParagraphFormattingEdit>
                  <dxhe:ToolbarFontNameEdit>
                    <Items>
                      <dxhe:ToolbarListEditItem Text="Times New Roman" Value="Times New Roman" />
                      <dxhe:ToolbarListEditItem Text="Tahoma" Value="Tahoma" />
                      <dxhe:ToolbarListEditItem Text="Verdana" Value="Verdana" />
                      <dxhe:ToolbarListEditItem Text="Arial" Value="Arial" />
                      <dxhe:ToolbarListEditItem Text="MS Sans Serif" Value="MS Sans Serif" />
                      <dxhe:ToolbarListEditItem Text="Courier" Value="Courier" />
                    </Items>
                  </dxhe:ToolbarFontNameEdit>
                  <dxhe:ToolbarFontSizeEdit>
                    <Items>
                      <dxhe:ToolbarListEditItem Text="1 (8pt)" Value="1" />
                      <dxhe:ToolbarListEditItem Text="2 (10pt)" Value="2" />
                      <dxhe:ToolbarListEditItem Text="3 (12pt)" Value="3" />
                      <dxhe:ToolbarListEditItem Text="4 (14pt)" Value="4" />
                      <dxhe:ToolbarListEditItem Text="5 (18pt)" Value="5" />
                      <dxhe:ToolbarListEditItem Text="6 (24pt)" Value="6" />
                      <dxhe:ToolbarListEditItem Text="7 (36pt)" Value="7" />
                    </Items>
                  </dxhe:ToolbarFontSizeEdit>
                  <dxhe:ToolbarBoldButton BeginGroup="True">
                  </dxhe:ToolbarBoldButton>
                  <dxhe:ToolbarItalicButton>
                  </dxhe:ToolbarItalicButton>
                  <dxhe:ToolbarUnderlineButton>
                  </dxhe:ToolbarUnderlineButton>
                  <dxhe:ToolbarStrikethroughButton>
                  </dxhe:ToolbarStrikethroughButton>
                  <dxhe:ToolbarJustifyLeftButton BeginGroup="True">
                  </dxhe:ToolbarJustifyLeftButton>
                  <dxhe:ToolbarJustifyCenterButton>
                  </dxhe:ToolbarJustifyCenterButton>
                  <dxhe:ToolbarJustifyRightButton>
                  </dxhe:ToolbarJustifyRightButton>
                  <dxhe:ToolbarJustifyFullButton>
                  </dxhe:ToolbarJustifyFullButton>
                </Items>
              </dxhe:StandardToolbar2>
            </Toolbars>
            <Styles>
              <ViewArea>
                <Border BorderColor="#4986A2" BorderStyle="Solid" BorderWidth="1px" />
              </ViewArea>
            </Styles>
            <PartsRoundPanel>
              <TopLeftCorner Height="5px" Width="5px" />
              <NoHeaderTopLeftCorner Height="5px" Width="5px" />
              <TopRightCorner Height="5px" Width="5px" />
              <NoHeaderTopRightCorner Height="5px" Width="5px" />
              <BottomRightCorner Height="5px" Width="5px" />
              <BottomLeftCorner Height="5px" Width="5px" />
              <HeaderLeftEdge>
                <BackgroundImage Repeat="RepeatX" VerticalPosition="bottom" />
              </HeaderLeftEdge>
              <HeaderContent>
                <BackgroundImage Repeat="RepeatX" VerticalPosition="bottom" />
              </HeaderContent>
              <HeaderRightEdge>
                <BackgroundImage VerticalPosition="bottom" />
              </HeaderRightEdge>
              <NoHeaderTopEdge BackColor="#EBF2F4">
              </NoHeaderTopEdge>
              <RightEdge>
                <BackgroundImage Repeat="RepeatX" VerticalPosition="bottom" />
              </RightEdge>
              <BottomEdge BackColor="#D7E9F1">
              </BottomEdge>
              <LeftEdge>
                <BackgroundImage Repeat="RepeatX" VerticalPosition="bottom" />
              </LeftEdge>
              <Content>
                <BackgroundImage Repeat="RepeatX" VerticalPosition="bottom" />
              </Content>
            </PartsRoundPanel>
            <StylesRoundPanel>
              <ControlStyle BackColor="#EBF2F4">
                <Border BorderStyle="Solid" BorderColor="#7EACB1" BorderWidth="1px" />
              </ControlStyle>
            </StylesRoundPanel>
            <StylesToolbars>
              <Toolbar SeparatorHeight="100%" ItemSpacing="0px">
              </Toolbar>
            </StylesToolbars>
            <StylesStatusBar>
              <Tab>
                <Paddings PaddingBottom="5px" PaddingTop="4px" />
              </Tab>
              <ActiveTab>
                <Paddings PaddingBottom="5px" PaddingTop="4px" />
              </ActiveTab>
              <StatusBar TabSpacing="0px">
              </StatusBar>
            </StylesStatusBar>
          </dxhe:ASPxHtmlEditor>
        </td>
      </tr>
    </table>
    <div>
    </div>
  </div>
  <div style="float: left; padding-top: 10px; padding-left: 160px;" id="divButton">
    <dxe:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="<%$ Resources:Strings, Save %>">
      <ClientSideEvents Click="function(s,e){onSave();e.processOnServer = false;}" />
    </dxe:ASPxButton>
  </div>
  <div style="float: left; padding-left: 3px; padding-top: 10px;">
    <dxe:ASPxButton ID="ASPxButton3" runat="server" Text="<%$ Resources:Strings, BackTo %>">
      <ClientSideEvents Click="function(s,e){onBack();e.processOnServer = false;}" />
    </dxe:ASPxButton>
  </div>
  <div>
    <asp:HiddenField ID="hfTypeId" runat="server" />
    <asp:HiddenField ID="hfNewsId" runat="server" />
    <asp:HiddenField ID="hfSettingPage" runat="server" />
    <asp:XmlDataSource ID="xdsLanguage" runat="server" DataFile="~/App_Data/Status.xml"
      XPath="Items/LanguageDisplay/Status"></asp:XmlDataSource>
    <asp:XmlDataSource ID="xdsCategoryType" runat="server" DataFile="~/App_Data/Status.xml"
      XPath="Items/CategoryType/Status"></asp:XmlDataSource>
    <dxe:ASPxCheckBox ID="ckbCanApprove" ClientInstanceName="ckbCanApprove" runat="server"
      ClientVisible="false">
    </dxe:ASPxCheckBox>
  </div>

  <script type="text/javascript" language="javascript">
    function checkCategory() {
      var error = '';
      if (txtCategoryName.GetText() == '')
        error += '<BR> + <%=(string)GetGlobalResourceObject("Strings","NewsCategory") %>';
      if (cbxLanguage.GetValue() == '')
        error += '<BR> + <%=(string)GetGlobalResourceObject("Strings","Language") %>';
      if (error != '') {
        alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0008") %>' + error);
        return false;
      }
      return true;
    }

    function Reset() {
      txtCategoryName.SetText('');
      txtDescription.SetText('');
      cbxLanguage.SetValue('');
    }
    function onAddCategory() {
      Reset();
      pcAddCategory.Show();
    }
    function onSaveCategory() {
      if (checkCategory()) {
        pcAddCategory.Hide();
        ctrlCallback.SendCallback("AddCategory");

      }
    }
    function onCancel() {
      pcAddCategory.Hide();
    }

    function showEditor(show) {
      var frmNewsInfo = document.getElementById('frmNewsInfo');
      var frmNewsContent = document.getElementById('frmNewsContent');
      var divButtons = document.getElementById('divButton');

      if (show) {
        frmNewsContent.style.display = 'block';
        frmNewsInfo.style.display = 'none';
        htmlEditor.AdjustControl();
        divButtons.style.paddingLeft = '56px';
      }
      else {
        frmNewsContent.style.display = 'none';
        frmNewsInfo.style.display = 'block';
        divButtons.style.paddingLeft = '168px';
      }
    }

    function onBack() {
      var typeId = document.getElementById('<%=hfTypeId.ClientID %>').value;
      var settingId = document.getElementById('<%=hfSettingPage.ClientID %>').value;
      var page = 'NewsList.aspx?t=' + typeId;
      //var page = 'NewsList.aspx';
      if (settingId == 27 || settingId == 28)
        page = 'NewsSetting.aspx?tid=' + settingId;
      window.location.href = page;
    }

    function onSave() {
      if (checkInput()) {
        pcWaiting.Show();
        ctrlCallback.SendCallback('Save|' + getImageName());
      }
    }

    function onDelete() {
      if (confirm('<%=(string)GetGlobalResourceObject("Messages", "ERR0006") %>'))
        ctrlCallback.SendCallback('Delete|');
    }

    function checkInput() {
      var error = '';
      if (txtTitle.GetText() == '')
        error += '<BR> + <%=(string)GetGlobalResourceObject("Strings","Title") %>';
      if (error != '') {
        alertMessage('<%=(string)GetGlobalResourceObject("Messages", "ERR0008") %>' + error);
        return false;
      }
      return true;
    }

    function ctrlCallback_CallbackComplete(s, e) {
      pcWaiting.Hide();
      if (e.parameter.indexOf('Save') >= 0) {
        if (e.result != '') {
          var para = e.result.split('|');
          if (para[0] == 'OK') {
            if (para[2] == 'Approval') {
              lblApprovedBy.SetText(para[3]);
              lblApprovedDate.SetText(para[4]);
              document.location.href = document.location.href;
            }
            document.getElementById('<%=hfNewsId.ClientID %>').value = para[1];
            
          }
          else {
            alertMessage(e.result);
            return;
          }
        }
        alertSuccess();
        return;
      }
      if (e.parameter == 'AddCategory') {
        if (e.result != '') {
          alertMessage(e.result);
        }
        else {
          window.location.href = 'NewsDetail.aspx';
        }
      }
    }

    function disableControls() {
      var disabled = false;
      btnSave.SetEnabled(disabled);
      hideUpload();
    }

    function onTabChange(s, e) {
      var tabName = e.tab.name;
      if (tabName == "NewsContent")
        showEditor(true);
      else
        showEditor(false);
    }
  </script>

</asp:Content>
